// FoodProduct.java
package org.example.model;

import java.math.BigDecimal;

public class FoodProduct extends Product {
    private String expiryDate;
    private String manufacturer;

    public FoodProduct(String id, String name, BigDecimal price, int quantity,
                       String expiryDate, String manufacturer) {
        super(id, name, price, quantity);
        setExpiryDate(expiryDate);
        setManufacturer(manufacturer);
    }

    // Getter和Setter方法
    public String getExpiryDate() { return expiryDate; }

    public void setExpiryDate(String expiryDate) {
        if (expiryDate == null || expiryDate.trim().isEmpty()) {
            throw new IllegalArgumentException("保质期不能为空");
        }
        this.expiryDate = expiryDate;
    }

    public String getManufacturer() { return manufacturer; }

    public void setManufacturer(String manufacturer) {
        if (manufacturer == null || manufacturer.trim().isEmpty()) {
            throw new IllegalArgumentException("生产商不能为空");
        }
        this.manufacturer = manufacturer;
    }

    @Override
    public void displayInfo() {
        System.out.println("=== 食品信息 ===");
        System.out.println("ID: " + getId());
        System.out.println("名称: " + getName());
        System.out.println("价格: ¥" + getPrice());
        System.out.println("库存: " + getQuantity());
        System.out.println("保质期: " + expiryDate);
        System.out.println("生产商: " + manufacturer);
        System.out.println("-------------------");
    }
}